package com.yiqi.lottery.feature.mine.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.yiqi.lottery.entity.bo.EditPwdBo;
import com.yiqi.lottery.entity.bo.RegisterBo;
import com.yiqi.lottery.entity.bo.TokenBo;
import com.yiqi.lottery.entity.bo.UploadBo;
import com.yiqi.lottery.feature.login.dependencies.login.DaggerLoginModelComponent;
import com.yiqi.lottery.feature.mine.contract.MineContract;
import com.yiqi.lottery.feature.mine.dependencies.mine.DaggerMineModelComponent;
import com.yiqi.lottery.framework.api.ApiLib;
import com.yiqi.lottery.framework.api.UserApi;
import io.reactivex.Observable;

import javax.inject.Inject;

public class MineModel implements MineContract.Model {

    @Inject
    UserApi api;


    @Inject
    public MineModel() {

        DaggerMineModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }

    @Override
    public Observable<UserInfoBo> getUsertInfo() {
        return api.getUserInfo().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> getUserAuth(RegisterBo registerBo) {
        return api.mineUserAuth(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> getEditPassword(EditPwdBo editPwdBo) {
        return api.editPwd(editPwdBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> userSendCode(String mobile) {
        return api.userRegisterSendCode(mobile).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<TokenBo> getQiniuToken() {
        return api.getQiniuToken().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<UserInfoBo> editUserInfo(Integer userId, UserInfoBo userInfoBo) {
        return api.editUserInfo(userId,userInfoBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

}
